package com.luban.learn.springmvc;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello")
public class HelloServlet extends HttpServlet {

    @Override
    public ServletConfig getServletConfig() {
        return super.getServletConfig();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String contextConfigLocation = this.getServletConfig().getInitParameter("contextConfigLocation");
        resp.setContentType("text/html");
        resp.getWriter().write("<h1>hello world: " + contextConfigLocation + " </h1>");
    }
}
